/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */

package com.ecarx.systemui.plugin.controller;

import android.content.Context;

import com.ecarx.systemui.plugin.model.wifi.WifiItemBean;
import com.ecarx.systemui.plugin.PluginContext;
import com.ecarx.systemui.plugin.model.wifi.IWifiApi;
import com.ecarx.systemui.plugin.model.wifi.WifiImpl;

import java.util.List;

public class WifiController {

    private static WifiController mController;
    private IWifiApi mWifiApi;

    public static synchronized WifiController getInstance() {
        if (mController == null) {
            mController = new WifiController();
        }
        return mController;
    }

    private Context mContext;

    private WifiController(){
        mContext = PluginContext.getContextByActThread();
        setWifiImpl(WifiImpl.getInstance());
    }


    public void setWifiImpl(IWifiApi wifiApi){
        mWifiApi = wifiApi;
    }

    //-1 不可用户 0 关 1 开
    public WifiState getWifiState(){
        return mWifiApi.getWifiState();
    }

    //打开
    public void openWifi(IWifiApi.IWifiResult result){
        mWifiApi.openWifi(result);
    }

    public void closeWifi(IWifiApi.IWifiResult result){
        mWifiApi.closeWifi(result);
    }

    public void connect(WifiItemBean bean, IWifiApi.IWifiResult result){
        mWifiApi.connect(bean,result);
    }

    public void forget(WifiItemBean bean,IWifiApi.IWifiResult result){
        mWifiApi.forget(bean,result);
    }

    public List<WifiItemBean> getScanList(){
        return mWifiApi.getScanInfoList();
    }

    public WifiItemBean connected(){
        return mWifiApi.connected();
    }

    public enum WifiState{
        OPEN,CLOSE,DISABLE
    }
}
